package com.rd.sys.common.utils.client;

import com.rd.sys.common.base.CommonConstants;
import com.rd.sys.common.utils.CommonUtils;
import com.rd.sys.common.utils.GetWebConfig;

/**
 * @author admin
 */
public class AnalysisPathUtils {
    private static final String userProjectBasePath = CommonUtils.judgeConfigPath(GetWebConfig
            .getValue("user.project.base.path"));


    public static String getUserBasePath(){
        return userProjectBasePath+CommonConstants.SysParamConstants.FILE_SEPARATOR;
    }

    /**
     * 获取用户编码所在目录
     *
     * @param userCode
     * @return
     */
    public static String findUserPath(String userCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode;
        return path;
    }

    /**
     * 获取项目所在目录
     *
     * @param userCode
     * @param projectCode
     * @return
     */
    public static String findProjectPath(String userCode, String projectCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + projectCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR;
        return path;
    }

    /**
     * 获取项目描述文件名
     *
     * @param userCode
     * @return
     */
    public static String findProjectFileName(String userCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.PROJECT_DESCRIPTION_FILENAME;
        return path;
    }

    /**
     * 获取方案所在目录
     *
     * @param userCode
     * @param projectCode
     * @return
     */
    public static String findSchemePath(String userCode, String projectCode, String schemeCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + projectCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + schemeCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR;
        return path;
    }

    /**
     * 获取方案所在目录
     *
     * @param projectPath 项目所在目录
     * @param schemeCode
     * @return
     */
    public static String findSchemePath(String projectPath, String schemeCode) {
        String path = projectPath + CommonConstants.SysParamConstants.FILE_SEPARATOR + schemeCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR;
        return path;
    }

    /**
     * 获取方案描述文件名
     *
     * @param userCode
     * @param projectCode
     * @return
     */
    public static String findSchemeFileName(String userCode, String projectCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + projectCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.SCHEME_DESCRIPTION_FILENAME;
        return path;
    }

    /**
     * 获取被试描述文件名
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @return
     */
    public static String findResultFileName(String userCode, String projectCode, String schemeCode) {
        String path = findSchemePath(userCode, projectCode, schemeCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.RESULT_DESCRIPTION_FILENAME;

        return path;
    }

    /**
     * 获取被试数据所在目录
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     */
    public static String findResultDataPath(String userCode, String projectCode, String schemeCode, String resultCode) {
        String path = findSchemePath(userCode, projectCode, schemeCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + resultCode;
        return path;
    }

    /**
     * 获取被试数据文件名(处理后)
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     */
    public static String findResultDataFileName(String userCode, String projectCode, String schemeCode,
                                                String resultCode) {
        String path = findResultDataPath(userCode, projectCode, schemeCode, resultCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.DATA_PROCESSED_FILENAME;
        return path;
    }

    /**
     * 获取事件处理结果数据明细
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return java.lang.String
     * @title 》findEventDataFileName
     * @author admin
     * @date 2019-12-30 13:33
     * @since v1.0.1
     **/
    public static String findEventDataFileName(String userCode, String projectCode, String schemeCode,
                                               String resultCode) {
        String path = findResultDataPath(userCode, projectCode, schemeCode, resultCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.EVENT_DESCRIPTION_FILENAME;
        return path;
    }

    /**
     * 获取被试数据文件名(未处理)
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     */
    public static String findResultRawDataFileName(String userCode, String projectCode, String schemeCode,
                                                   String resultCode) {
        String path = findResultDataPath(userCode, projectCode, schemeCode, resultCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + CommonConstants.AnalysisConstats.DATA_RAW_FILENAME;
        return path;
    }

    /**
     * 获取素材文件名(含全路径)
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param materialName
     * @return
     */
    public static String findMaterialFile(String userCode, String projectCode, String schemeCode, String materialCode,
                                          String materialSuffix) {
        String path = findSchemePath(userCode, projectCode, schemeCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + materialCode + materialSuffix; // 兼容客服端,后缀是带了符号点的,如".jpg"
        return path;
    }

    /**
     * 获取被试注视点统计数据文件名(处理后)
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     */
    public static String findResultDataStatisticFixationFileName(String userCode, String projectCode,
                                                                 String schemeCode, String resultCode) {
        String path = findResultDataPath(userCode, projectCode, schemeCode, resultCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.DATA_STATISTIC_FIXATION_FILENAME;
        return path;
    }

    /**
     * 获取被试扫视点统计数据文件名(处理后)
     *
     * @param userCode
     * @param projectCode
     * @param schemeCode
     * @param resultCode
     * @return
     */
    public static String findResultDataStatisticSaccadeFileName(String userCode, String projectCode, String schemeCode,
                                                                String resultCode) {
        String path = findResultDataPath(userCode, projectCode, schemeCode, resultCode)
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.DATA_STATISTIC_SACCADE_FILENAME;
        return path;
    }

    /**
     * 获取AOI数据文件名
     *
     * @param userCode
     * @param projectCode
     * @return
     */
    public static String findAoiDataFileName(String userCode, String projectCode, String schemeCode) {
        String path = userProjectBasePath + CommonConstants.SysParamConstants.FILE_SEPARATOR + userCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + projectCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR + schemeCode
                + CommonConstants.SysParamConstants.FILE_SEPARATOR
                + CommonConstants.AnalysisConstats.AOI_DESCRIPTION_FILENAME;
        return path;
    }
}
